package com.qdlc.p2p.biz.processor.task;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.qdlc.p2p.biz.processor.event.BorrowValueEvent;
import com.qdlc.p2p.biz.service.AutoBorrowService;
import com.qdlc.p2p.common.core.queue.TaskProcessorException;
import com.qdlc.p2p.common.core.queue.ValueEvent;
import com.qdlc.p2p.dal.model.BorrowModel;


/**
 * 自动投标
 * @author linya 2015-12-30
 */
@Service
public class TenderAutoTaskProcessor extends AbstractTaskProcessor {

	private static final Logger logger = Logger.getLogger(TenderAutoTaskProcessor.class);
	
	@Resource
	AutoBorrowService autoBorrowService;
	
	@Override
	public boolean supports(ValueEvent event) {
		return event instanceof BorrowValueEvent;
	}

	@Override
	public void process0(ValueEvent event) throws TaskProcessorException {
		BorrowValueEvent borrowEvent = (BorrowValueEvent)event;
		BorrowModel borrowModel = borrowEvent.getBorrowModel();
		logger.info("代收投资金(1001)业务队列处理(自动投标请求) START 订单号[" + borrowModel.getTenderBilNo() + "]");
		try {
			autoBorrowService.autoDealTender(borrowModel);
		} catch (Exception e) {
			logger.info("代收投资金(1001)业务队列处理异常  订单号[" + borrowModel.getTenderBilNo() + "]");
			logger.error(e.getMessage(), e);
		}
		logger.info("代收投资金(1001)业务队列处理 END 订单号[" + borrowModel.getTenderBilNo() + "]");
	}

}
